package it.bit.jlightqueryer;

import it.bit.jlightqueryer.gui.MainChooser;

import java.awt.Image;
import java.awt.Toolkit;

import javax.swing.UIManager;

/**
 * Starting class for JLightQueryer
 * @author PerezDeQueya80
 */
public class Start {

	public static final String VERSION = "1.0.1";

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			String jvmVer = System.getProperty("java.version");
			if ("1.5".compareTo(jvmVer)<=0)
		    try {
		    	if (System.getProperty("os.name").toUpperCase().indexOf("WINDOWS") != -1) {
			    	UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
		    	}
		    	else {
			    	System.out.println(UIManager.getCrossPlatformLookAndFeelClassName());
		    	}
		    } catch (Exception e) {
				e.printStackTrace();
		    }
		    MainChooser mainChooser = new MainChooser();
		    mainChooser.setVisible(true);
		}
		catch (Exception e) {
			e.printStackTrace();
			System.exit(0);
		}
	}

	/**
	 * Utility method to get directly an image from image package
	 * @param img
	 * @return
	 */
	public static Image getImageResource(String img) {
		byte[] imagedata = new byte[0];
		try {
			java.net.URL url = Start.class.getResource("images/"+img);
			java.io.InputStream is = url.openStream();

			int size = is.available();
			imagedata = new byte[size];
			is.read(imagedata);
		}
		catch (Exception e) {
		}
		return Toolkit.getDefaultToolkit().createImage(imagedata);
	}

}
